package com.batis.source.session;

import com.batis.source.builder.xml.MYXMLConfigBuilder;
import com.batis.source.session.defaults.MYDefaultSqlSessionFactory;

import java.io.Reader;

/**
 * sql会话工厂
 * @author isam2016
 * @create 2021-08-26 11:07 AM
 */
public class MYSqlSessionFactoryBuilder {
     public MYSqlSessionFactory build(Reader reader){
         // xml 文件构建器
         MYXMLConfigBuilder parser = new MYXMLConfigBuilder(reader, null, null);
         return build(parser.parse());
     }
    public MYSqlSessionFactory build(MYConfiguration config) {
        /**
         *  public Environment(String id, TransactionFactory transactionFactory, DataSource dataSource) {
         *     this.id = id;
         *     this.transactionFactory = transactionFactory;
         *     this.dataSource = dataSource;  缺失datasource
         *   }
         */
        return new MYDefaultSqlSessionFactory(config);
    }
}
